package teatime.core.bussiness.base;

import teatime.core.model.entity.Account;
import teatime.core.service.manager.AccountManager;

public abstract class BaseLogin implements LoginManager {

	private AccountManager<Account> accountManager;
	private Account account;
	private String accountName;
	private String accountPassword;

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public String getAccountPassword() {
		return accountPassword;
	}

	public void setAccountPassword(String accountPassword) {
		this.accountPassword = accountPassword;
	}

	public BaseLogin() {
		initialize();
	}

	private void initialize() {
		// TODO Auto-generated method stub
	}

	public BaseLogin(String accountName, String accountPassword) {
		this.accountName = accountName;
		this.accountPassword = accountPassword;
	}
	
	public String Login() {
		account = accountManager.findUniqueBy(Account.PROP_ACCOUNT_NAME,
				accountName);
		if (!account.equals(null)) {
			if (account.getAccountPassword().equals(accountPassword)) {
				return "passed";
			}
		}
		return "faile";
	}

	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

}
